package com.kzj.mls.recyclerCard.cardView;

import android.content.Context;
import android.util.AttributeSet;

import com.ab.util.AbViewUtil;
import com.kzj.mls.R;
import com.kzj.mls.global.App;
import com.kzj.mls.recyclerCard.basic.CardItemView;
import com.kzj.mls.recyclerCard.basic.MaterialListView;
import com.kzj.mls.recyclerCard.card.fragmentMain.DirectoryCard;
import com.kzj.mls.recyclerCard.card.fragmentMain.MaterilistViewDirCard;

/**
 * Created by xyg on 2015/10/26.
 */
public class MaterilistViewDirCardView extends CardItemView<MaterilistViewDirCard> {

    private Context context;
    private MaterialListView material_listview;

    //  private CirclePageIndicator circlePageIndicator;
    public MaterilistViewDirCardView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public MaterilistViewDirCardView(Context context) {
        super(context);
        this.context = context;
    }

    public MaterilistViewDirCardView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    @Override
    public void build(MaterilistViewDirCard card) {
        super.build(card);
        material_listview = (MaterialListView) findViewById(R.id.material_listview);
        double row = Math.ceil((double) card.getIndexServiceBeanList().size() / 2);
        material_listview.getLayoutParams().height = AbViewUtil.scaleValue(context, (float) (810 / 3 * row));
        material_listview.getLayoutParams().width = App.getInstance().screenWidth;
        material_listview.setColumnLayout(2);
        // RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) material_listview.getLayoutParams();
        // layoutParams.setMargins();
        initData(card);
        AbViewUtil.scaleView(material_listview);
        AbViewUtil.scaleView(this);
        material_listview.setTag(AbViewUtil.NotScale);
        this.setTag(AbViewUtil.NotScale);
        setNeedScale(false);
    }

    private void initData(MaterilistViewDirCard card) {
        material_listview.clear();
        for (int j = 0; j < card.getIndexServiceBeanList().size(); j++) {
/*

            DirectoryBean directoryBean=new DirectoryBean();
            if (j==0)
            {
                directoryBean.setImageUrl("drawable://" + R.drawable.tuoming);
                directoryBean.setTitle("脱敏 Action");
                directoryBean.setBackcColor(R.drawable.shape_green_7ee1cb);

            }else if (j==1)
            {
                directoryBean.setImageUrl("drawable://" + R.drawable.shuinengmeibai);
                directoryBean.setTitle("全校水嫩美白");
                directoryBean.setBackcColor(R.drawable.shape_blue_7dd5e8);
            }else if (j==2)
            {
                directoryBean.setImageUrl("drawable://" + R.drawable.bushui);
                directoryBean.setTitle("玻尿酸补水");
                directoryBean.setBackcColor(R.drawable.shape_purple_a4a5d5);
            }else if (j==3)
            {
                directoryBean.setImageUrl("drawable://" + R.drawable.yaozhuangqudou);
                directoryBean.setTitle("进口药妆祛痘");
                directoryBean.setBackcColor(R.drawable.shape_green_9fcf9f);
            }else if (j==4)
            {
                directoryBean.setImageUrl("drawable://" + R.drawable.jianjingtiaoli);
                directoryBean.setTitle("肩颈调理");
                directoryBean.setBackcColor(R.drawable.shape_green_8ad3b0);
            }else if (j==5)
            {
                directoryBean.setImageUrl("drawable://" + R.drawable.ruxianshutong);
                directoryBean.setTitle("乳腺疏通");
                directoryBean.setBackcColor(R.drawable.shape_red_ffc0c0);
            }*/

            DirectoryCard directoryCard = new DirectoryCard(context);
            directoryCard.setIndexServiceBean(card.getIndexServiceBeanList().get(j));
            material_listview.add(directoryCard);

        }
    }
}
